import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Page from '../views/Page.vue'

Vue.use(VueRouter)

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Page',
    component: () => import('../views/Page.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/page',
    name: 'Page',
    component: () => import('../views/Page.vue'),
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        component: () => import('../views/Welcome.vue'),
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/dataAnalysis',
        name: 'dataAnalysis',
        component: () => import('../views/graduateInfo/DataAnalysis.vue'),
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/infoMaintain',
        name: 'infoMaintain',
        component: () => import('../views/graduateInfo/InfoMaintain.vue'),
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/hotTechnical',
        name: 'hotTechnical ',
        component: () => import('../views/graduationProject/HotTechnical .vue'),
        meta: {
          keepAlive: false
        }
      },
      {
        path: '/thesisUpload',
        name: 'thesisUpload',
        component: () => import('../views/graduationProject/ThesisUpload.vue'),
        meta: {
          keepAlive: true                   //需要缓存的组件
        }
      },
      {
        path: '/knowledgeGraph',
        name: 'knowledgeGraph',
        component: () => import('../views/graduationProject/KnowledgeGraph.vue'),
        meta: {
          keepAlive: false                  //不需要缓存的组件
        }
      },
      {
        path: '/userMaintain',
        name: 'userMaintain',
        component: () => import('../views/userManage/UserMaintain.vue'),
        meta: {
          keepAlive: false                  //不需要缓存的组件
        }
      }
    ]
  }
]



const router = new VueRouter({
  routes
})

export default router
